import 'package:flutter/material.dart';
import 'package:flutter_app_demo/redux_demo/redux_demo.dart';

class AddItemWidget extends StatefulWidget {
    
    final ViewModel model;
    
    AddItemWidget(this.model);
    
    @override
    _AddItemWidgetState createState() => _AddItemWidgetState();
}

class _AddItemWidgetState extends State<AddItemWidget> {
    
    final TextEditingController controller = TextEditingController();
    
    @override
    Widget build(BuildContext context) {
        return TextField(
            controller: controller,
            decoration: InputDecoration(
                hintText: "add an Item",
            ),
            onSubmitted: (String str) {
                widget.model.onAddItem(str);
                controller.text = '';
            },
        );
    }
}
